package com.it.selfrequest.mapper;

import com.it.selfrequest.pojo.Test;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TestMapper {

    @Insert("insert into test(username, gender,age,address,hobby) values(#{username}, #{gender}, #{age}, #{address}, #{hobby})")
    int save(Test test);

    /**
     * 获取全部数据
     *
     * @return
     */
    @Select("select * from test")
    List<Test> getTestAll();

    /**
     * 根据id获取数据
     *
     * @param id
     * @return
     */
    @Select("select * from test where id = #{id}")
    Test getTestById(Long id);

    @Update("update test set username=#{username}, age=#{age},gender=#{gender}, address=#{address}, hobby=#{hobby} where id=#{id}")
    int update(Test test);

    @Delete("DELETE FROM test WHERE id=#{id} ")
    int deleteById(Long id);

    @Select("select * from test where username = #{username}")
    List<Test> getTestByUsername(String username);

    @Delete("DELETE FROM test WHERE id in (#{ids})")
    int deleteTestByIds(@Param("ids") List<Long> ids);
}
